from faker import Faker
import random
import openpyxl
def fakedata(data):
    title=['姓名','地址','邮箱','电话号码']
    user=[]
    code=['zh_TW','zh_CN','hy_AM','en_CA']
    data.append(title)
    for i in range(100):
        index = random.randint(0, 3)
        faker=Faker(locale=code[index])
        user.append(faker.name())
        user.append(faker.address())
        user.append(faker.email())
        user.append(faker.msisdn())
        data.append(user)
        user=[]
    return data
##开始把数据导入excel,再写一遍这里不封装了就
data=fakedata([])
wb=openpyxl.load_workbook('user.xlsx')
mysheet=wb.create_sheet('mydata')
for row in data:
    mysheet.append(row)
wb.save('user.xlsx')

